//------------------------------------------------------------------------------
// <copyright company="Telligent Systems">
//     Copyright (c) Telligent Systems Corporation.  All rights reserved.
// </copyright> 
//------------------------------------------------------------------------------

using System;
using System.IO;
using System.Text;
using System.Web.UI;

namespace CommunityServer.Components
{
	/// <summary>
	/// Summary description for CSFormPage.
	/// </summary>
	public class CSFormPage : CSPage
	{
		public CSFormPage()
		{
			//
			// TODO: Add constructor logic here
			//
		}

        protected override void Render(System.Web.UI.HtmlTextWriter writer)
        {
            StringBuilder stringBuilder = new StringBuilder();
            StringWriter stringWriter = new StringWriter(stringBuilder);
            HtmlTextWriter htmlWriter = new HtmlTextWriter(stringWriter);
            base.Render(htmlWriter);
            string html = stringBuilder.ToString();

            int start = html.IndexOf("<form name=\"") + 12;
            
            if(start != 11)
            {
                int end = html.IndexOf("\"", start);
                string formID = html.Substring(start, end - start);
                string replace = formID.Replace(":", "_");
                html = html.Replace("document." + formID, "document." + replace);
             
            }
               writer.Write(html);
        }

	}
}
